<?php

namespace app\admin\controller;

use app\common\controller\Backend;

/**
 * 加工费
 *
 * @icon fa fa-circle-o
 */
class Clothfee extends Backend
{

    /**
     * Clothfee模型对象
     * @var \app\admin\model\Clothfee
     */
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\Clothfee;

    }


    public function index()
    {
    	//设置过滤方法
    	$this->request->filter(['strip_tags', 'trim']);
    	if (false === $this->request->isAjax()) {
    		$this->assignconfig("Clothbank", db('clothbank')->where('deletetime', null)->column('name','id'));
    		$this->assignconfig("Clothtype", db('clothtype')->where('deletetime', null)->column('No','id'));
    		return $this->view->fetch();
    	}
    	//如果发送的来源是 Selectpage，则转发到 Selectpage
    	if ($this->request->request('keyField')) {
    		return $this->selectpage();
    	}
    	[$where, $sort, $order, $offset, $limit] = $this->buildparams();
    	$list = $this->model
			    	 ->where($where)
			    	 ->order($sort, $order)
			    	 ->paginate($limit);
    	$result = ['total' => $list->total(), 'rows' => $list->items()];
    	return json($result);
    }


}
